package reflect;

import java.util.Scanner;

public class ReflectDemo3 {
    public static void main(String[] args) {
        Person person = new Person();
        System.out.println(person);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入类名：");
        String className = scanner.nextLine();

        try {
            Class cls = Class.forName(className);
            Object obj = cls.newInstance();//new Person()
            System.out.println(obj);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
